package com.example.flshtarvel.service;

import com.example.flshtarvel.entity.Notes;
import com.example.flshtarvel.mapper.NotesMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service
public class NotesService {
    @Autowired(required = false)
    NotesMapper notesMapper;

    public int insertNotes(Notes notes){
        notes.setNotesId(UUID.randomUUID().toString());
        return notesMapper.insertNotes(notes);
    }

    public int updateNotes(Notes notes){
        return notesMapper.updateNotes(notes);
    }

    public int deleteNotes(String notesId){
        return notesMapper.deleteNotes(notesId);
    }

    public List<Notes> selectNotes(int page,int size){
        int offset = (page-1)*size;
        return notesMapper.selectNotes(offset,size);
    }

    public Notes selectNotesByNotesId(String notesId){
        return notesMapper.selectNotesByNotesId(notesId);
    }

    public List<Notes> selectNotesByUserId(String userId){

        return notesMapper.selectNotesByUserId(userId);
    }

    public Notes selectNotesById(String noteId){
        return notesMapper.selectNotesById(noteId);
    }

}
